﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ARS.Control.Custom.Entity.Fields;

namespace NetWebControl.ControlTest.OA
{

    internal class MyUser:ARS.Control.Custom.Entity.Model.EntityModel
    {
        public ForeignKeyConfig GetForeignKeyConfig()
        {
            ForeignKeyConfig config = new ForeignKeyConfig();
            config.TableName = "Users";
            config.KeyField = "Users_Id";
            config.DataTextField = "RealName";
            return config;
            //return base.ForeignKeyConfig();
        }
    }

    internal class Users_Permissions
    {
        [KeyField()]
        public int Users_Permissions_Id
        {
            get;
            set;
        }

        //[ChoicesDialogConfig(TableName = "Users", DataValueField = "Users_Id", DataTextField = "RealName")]
        //[ChoicesDialogField(Verbose_Name = "名称", ListUrl = "dp.aspx", MaxChoicesNum = 4, IsEncryptKey = true, DataTextClassName = "name1",IsShow=true)]
        //public string Name
        //{
        //    get;
        //    set;
        //}
        //[ChoicesField(Verbose_Name="编码",Choices="0|Add,1|Delete",IsShow=true)]
        //public string Code
        //{
        //    get;
        //    set;
        //}
        //[BooleanField(Verbose_Name="1",SelectValue="1",DefaultValue="1")]
        //public string Remark
        //{
        //    get;
        //    set;
        //}
        [ForeignKeyField()]
        public MyUser myUser
        {
            get; 
            set;
        }

        //[ChoicesDialogField(Verbose_Name = "代码", ListUrl = "dp.aspx", MaxChoicesNum = 3, DataTextIndex = 0, DataValueIndex = -1)]
        //public string Code
        //{
        //    get;
        //    set;
        //}

        //[ChoicesDialogField(Verbose_Name = "用户", ListUrl = "dp.aspx", MaxChoicesNum = 2, DataTextIndex = 0, DataValueIndex = -1)]
        //public int ParentId
        //{
        //    get;
        //    set;
        //}
    }

    public partial class adddialog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           // HX.Web.Users.Model.Users up = new HX.Web.Users.Model.Users();
            ARS.Fields.Users_Permissions up = new ARS.Fields.Users_Permissions();

            //MyFields.Users up = new MyFields.Users();

            //Company_Department up = new Company_Department();
            this.EntityModifyPanel1.Entity = up;
            this.EntityModifyPanel1.IsEncryptKey = false;

            int a = 1;

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.EntityModifyPanel1.AddOrUpdateEntityToDb();
        }
    }
}